//
//  TKYFindTreeViewCell.m
//  ProgressReportProject
//
//  Created by apple on 2018/4/28.
//  Copyright © 2018年 铁科院. All rights reserved.
//

#import "TKYFindTreeViewCell.h"
@interface TKYFindTreeViewCell()

@property (nonatomic, strong) UIImageView *img;
@property (nonatomic, strong) UILabel *textLbl;
@end
@implementation TKYFindTreeViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUpUi];
        
    }
    return self;
}

- (void)setUpUi {
    [self.contentView addSubview:self.img];
    [self.contentView addSubview:self.textLabel];
    
}

- (void)setQuestionTypeModel:(TKYQuestionTypeModel *)questionTypeModel{
    _questionTypeModel = questionTypeModel;
    _textLbl.text = questionTypeModel.name;
    if (questionTypeModel.isOpen) {
        _img.image = [UIImage imageNamed:@"sign_minus"];
    } else {
        _img.image = [UIImage imageNamed:@"sign_plus"];
    }
    
    _img.frame = CGRectMake(30 + (questionTypeModel.level - 1) * 15, 15, 15, 15);
    _textLbl.frame = CGRectMake(CGRectGetMaxX(_img.frame) + 15, 5 ,kScreenWidth -(30 + (questionTypeModel.level - 1) * 15) - 100 , 40);
    
    if ([questionTypeModel.isParent boolValue] == YES) {
        _img.hidden = NO;
    } else {
        _img.hidden = YES;
    }
}

- (void)setFindTreeModel:(TKYFindTreeModel *)findTreeModel {
    _findTreeModel = findTreeModel;
    _textLbl.text = findTreeModel.name;
    if (findTreeModel.isOpen) {
        _img.image = [UIImage imageNamed:@"sign_minus"];
    } else {
        _img.image = [UIImage imageNamed:@"sign_plus"];   
    }
    
    _img.frame = CGRectMake(30 + (findTreeModel.lv - 1) * 15, 15, 15, 15);
    _textLbl.frame = CGRectMake(CGRectGetMaxX(_img.frame) + 15, 25 /2 , 400, 20);
    
    if (findTreeModel.isParent == YES) {
        _img.hidden = NO;
    } else {
        _img.hidden = YES;
    }
    
    if (findTreeModel.isSelected == YES) {
        self.backgroundColor = KNavColor;
    }else{
        self.backgroundColor = [UIColor whiteColor];
    }
}

#pragma mark - LazyLoad
- (UIImageView *)img {
    if (!_img) {
        _img = [UIImageView new];
    }
    return _img;
}

- (UILabel *)textLabel {
    if (!_textLbl) {
        _textLbl = [UILabel new];
        _textLbl.numberOfLines = 0;
        _textLbl.font = Font(14);
    }
    return _textLbl;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
